//
//  BaseTableViewController.swift
//  SinaWeibo--swift
//
//  Created by 蒋春萌 on 15/10/6.
//  Copyright © 2015年 蒋春萌. All rights reserved.
//

import UIKit

class BaseTableViewController: UITableViewController,VisitorLoginViewDelegate{

    var visitorLoginView :VisitorLoginView?
    
    //loadView是苹果专门为手写代码准备的,一旦实现了此方法 所有xib/sb都会失效
    //当视图控制器被初始化后  它会自动检测view是否为空 如果为空 会自动调用loadView
    //在view没有被初始化之前不要跟踪view
    override func loadView() {
        
        visitorLoginView = NSBundle.mainBundle().loadNibNamed("VisitorLoginView", owner: nil, options: nil).last as? VisitorLoginView
        
        //        设置代理
        visitorLoginView?.visitorLoginDelegate = self
        
        view = visitorLoginView
        
//        添加导航栏item
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorWillRegister")
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorWillLogin")
    }
    
//    实现代理方法
    func visitorWillRegister(){
    
    }
    
    func visitorWillLogin(){
        
//      加载授权页面
        let sb = UIStoryboard(name: "OAuth", bundle: nil)
        let vc = sb.instantiateInitialViewController() as! UINavigationController
        presentViewController(vc, animated: true, completion: nil)
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()

        
        
        
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        
    }

}
